<script setup lang="ts">

import {ref} from "vue";
import SelectedArticles from "@/components/index/article/SelectedArticles.vue";

const active = ref(0);
const onClickLeft = () => history.back();

import { articleContent,} from "@/http/home";

// 文章列表请求
let articleList = ref<any[]>([])
articleContent({pageNum: 1, pageSize: 10}).then(res => {
    console.log(res)
    if (res.code == 200) {
        articleList.value = res.rows
    }

});

import {useRouter} from "vue-router";
// import EachAppointment from "@/components/gerenzhongxin/Content/Myconsultation/appointment/EachAppointment.vue";

//跳转到文章详情页面传参
const detailId = useRouter()

function jumpDetail(item) {
    detailId.push({
        path: '/textDetail',
        query: {id: item.id}
    })
}

// //文章分类请求
// let categoryList = ref<any[]>([])
// articleCategory({pageNum: 1, pageSize: 5}).then(res => {
//     console.log(res)
//     if (res.code==200){
//         categoryList.value=res.rows
//     }
// })
</script>

<template>
    <div>
        <van-nav-bar
                :border=false
                :fixed=true
                :placeholder=true
                title="文章"
                left-text="返回"
                left-arrow
                @click-left="onClickLeft"
        />
        <van-tabs v-model:active="active" color="#CEAFF8" :swipeable=true :sticky=true>
            <van-tab title="精选">
                <selected-articles v-for="item in articleList" :key="item.id" :articleInfo="item"
                                   @click="jumpDetail(item)"></selected-articles>
            </van-tab>
            <van-tab title="情绪">
                <template v-for="item in articleList" :key="item.id">
                    <selected-articles :articleInfo="item"  @click="jumpDetail(item)" v-if="item.psyCategoryVo?.name=='情绪'"></selected-articles>
                </template>
            </van-tab>
            <van-tab title="情感">
                <template v-for="item in articleList" :key="item.id">
                    <selected-articles :articleInfo="item"  @click="jumpDetail(item)" v-if="item.psyCategoryVo?.name=='情感'"></selected-articles>
                </template>
            </van-tab>
            <van-tab title="性格">
                <template v-for="item in articleList" :key="item.id">
                    <selected-articles :articleInfo="item"  @click="jumpDetail(item)" v-if="item.psyCategoryVo?.name=='性格'"></selected-articles>
                </template>
            </van-tab>
            <van-tab title="家庭">
                <template v-for="item in articleList" :key="item.id">
                    <selected-articles :articleInfo="item"  @click="jumpDetail(item)" v-if="item.psyCategoryVo?.name=='家庭'"></selected-articles>
                </template>
            </van-tab>
            <van-tab title="职场">
                <template v-for="item in articleList" :key="item.id">
                    <selected-articles :articleInfo="item"  @click="jumpDetail(item)" v-if="item.psyCategoryVo?.name=='职场'"></selected-articles>
                </template>
            </van-tab>
            <van-tab title="综合">
                <template v-for="item in articleList" :key="item.id">
                    <selected-articles :articleInfo="item"  @click="jumpDetail(item)" v-if="item.psyCategoryVo?.name=='综合'"></selected-articles>
                </template>
            </van-tab>

        </van-tabs>
    </div>
</template>

<style scoped>

</style>